package com.example.tbtx.tbtx.view;

import android.annotation.TargetApi;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;

import com.example.tbtx.tbtx.R;

public class ScaleInTransformer  implements ViewPager.PageTransformer
{
    private static final float DEFAULT_MIN_SCALE = 0.85f;
    private float mMinScale = DEFAULT_MIN_SCALE;

    public ScaleInTransformer()
    {

    }

    public ScaleInTransformer(float minScale)
    {
        this(minScale, NonPageTransformer.INSTANCE);
    }

    public ScaleInTransformer(ViewPager.PageTransformer pageTransformer)
    {
        this(DEFAULT_MIN_SCALE, pageTransformer);
    }


    public ScaleInTransformer(float minScale, ViewPager.PageTransformer pageTransformer)
    {
        mMinScale = minScale;
    }


    @Override
    public void transformPage(@NonNull View view, float position) {
        int pageWidth = view.getWidth();
        int pageHeight = view.getHeight();

        view.setPivotY(pageHeight / 2);
        view.setPivotX(pageWidth / 2);
        float abs = Math.abs(position);

        view.setScaleX((float) (1.5-(0.25*abs)));
        view.setScaleY((float) (1.5-(0.25*abs)));
        Log.d("", "pageTransform: "+position);
        view.setTranslationY(-80*abs);
    }
}
